package com.tingyuge.base.structrue.quene;

import java.util.Random;

/**
 * @Created by xiaodao
 */
public class Main {

    private static double testQueue(Queue<Integer> queue,int opcount){
        long startTime = System.nanoTime();
        Random random = new Random(System.currentTimeMillis());
        for (int i = 0; i < opcount ; i++) {
        queue.enQueue(random.nextInt(Integer.MAX_VALUE));
        }

        for (int i = 0; i <opcount ; i++) {
            queue.deQueue();
        }

        long endTime = System.nanoTime();
        return (endTime -startTime) / 1000000000.0;
    }

    private static double testQueue2(MyArrayQueue<Integer> queue,int opcount){
        long startTime = System.nanoTime();
        Random random = new Random(System.currentTimeMillis());
        for (int i = 0; i < opcount ; i++) {
            queue.push(random.nextInt(Integer.MAX_VALUE));
        }

        for (int i = 0; i <opcount ; i++) {
            queue.pop();
        }

        long endTime = System.nanoTime();
        return (endTime -startTime) / 1000000000.0;
    }
    public static void main(String[] args) {
        int opcount = 100000;
        ArrayQueue<Integer> queue = new ArrayQueue<>();
        double v = Main.testQueue(queue, opcount);
        System.out.println("arrayqueue:"+ v);
        LoopQueue<Integer> queue1 = new LoopQueue<>();
        System.out.println("我的队列:"+  Main.testQueue(queue1,opcount));
        MyArrayQueue<Integer> queue2 = new MyArrayQueue<>();
        System.out.println("路遥的队列:"+Main.testQueue2(queue2,opcount));
    }
}
